<template>
  <div class="demo">
    <template>
      <div v-if="mode === 'edit'">
        <van-dropdown-menu>
          <van-dropdown-item v-for="(list, index) in dropLists" :key="index" v-model="valueArr[index]" :options="list" @change="changedrop(valueArr[index], index)" />
        </van-dropdown-menu>
      </div>
    </template>
  </div>
</template>

<script>
export default {
  name: "dropdownMenu",
  mixins: [],
  components: {},
  props: {
    value: {},
    mode: {
      default: "edit", // 编辑模式和 edit， 展示模式 view
    },
    dropLists: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      valueArr: []
    };
  },
  computed: {},
  watch: {
  },
  created() {},
  mounted() {
    this.dropLists.forEach(i => this.valueArr.push(i[0].value))
  },
  methods: {
    changedrop(value,index) {
      this.$emit('update:switchMenu', {
        value: this.valueArr,
        currentValue: value,
        index: index
      })
    }
  },
};
</script>
<style lang="scss" scoped>
.demo {
  width: 100%;
  .van-cell {
    padding: 0;
  }
}
</style>
